package com.zhima.panel;

import com.zhima.function.ConfigurationIndexAssociate;
import com.zhima.function.RemoveSelectedRow;

import javax.swing.*;
import java.awt.*;

public class NewLineConfiguration extends RandomInDataConfiguration {
    public NewLineConfiguration(int rowIndex, RemoveSelectedRow removeSelectedRow, ConfigurationIndexAssociate configurationIndexAssociate) {
        super(removeSelectedRow, configurationIndexAssociate);
        setLayout(new FlowLayout(FlowLayout.LEFT));
        this.rowIndex = rowIndex;
        this.rowInfoJLabel = new JLabel(String.format("第 [ %d ] 块 ", rowIndex + 1));
        this.deleteJButton = new JButton("删除");
        deleteJButton.addActionListener(e -> removeSelectedRow.accept(this.rowIndex));
        add(rowInfoJLabel);
        add(new JLabel("\\n"));
        add(this.deleteJButton);
        initDataAssociationComponents();
        initDataAssociationActionListener();
        addDataAssociationComponents();
        dataAssociationComponentsToEdited();
    }
}
